package com.sky.mapper;

//import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {



    @Select("select count(*) from setmeal where status != 0 and category_id = #{categoryId} ")
    Integer setmealCountByCategoryId(Long categoryId);

    @AutoFill(OperationType.INSERT)
    @Insert("INSERT INTO setmeal (category_id, name, price, description, image, create_time, create_user, update_time, update_user) " +
            "VALUES " +
            "(#{categoryId}, #{name}, #{price}, #{description}, #{image}, #{createTime}, #{createUser}, #{updateTime}, #{updateUser})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void saveSetmeal(Setmeal setmeal);

    Page<SetmealVO> getSetmeals(SetmealPageQueryDTO dto);

    @Select("select * from setmeal where id = #{id}")
    Setmeal getSetmealById(Integer id);

    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    void deleteSetmeals(List<Long> ids);

    void updateSetmealStatusByDish(List<Long> ids, Long currentId);

    @Select("select * from setmeal where category_id = #{categoryId}")
    List<Setmeal> getSetmealByCategoryId(Integer categoryId);
}
